using System;
using NHibernate;
using Sample.Domain;

namespace Sample.Service
{
    public class PeerReviewService : Repository<PeerReview>
    {
        public PeerReviewService(ISession session)
            : base(session)
        {
        }

        public void SaveChanges(PeerReview review)
        {
            try
            {
                using (var transaction = _session.BeginTransaction())
                {
                    base.SaveOrUpdate(review);
                    transaction.Commit();
                }
            }
            catch (Exception)
            {
                if (_session.Transaction != null && _session.Transaction.IsActive) _session.Transaction.Rollback();
                throw;
            }
        }
    }
}